package org.lt.ttkv.store;

import androidx.annotation.NonNull;

import org.lt.ttkv.utils.SPUtils;


/**
 * @ClassName: DefaultKVTool
 * @Description: 类作用描述
 * @Author: wtl
 * @CreateDate: 2023/7/5 19:34
 * @UpdateUser: 更新者 wtl
 * @UpdateDate: 2023/7/5 19:34
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
public class DefaultKVTool implements KVTool {

  private SPUtils mSPUtils;
  private String groupName;

  public void init(@NonNull String groupName) {
    this.groupName = groupName;
    mSPUtils = SPUtils.getInstance(groupName);
  }
  @Override
  public String getGroupName() {
    return groupName;
  }

  @Override
  public void put(@NonNull String keyName, Integer i) {
    mSPUtils.put(keyName, i);
  }

  @Override
  public void put(@NonNull String keyName, Long l) {
    mSPUtils.put(keyName, l);
  }

  @Override
  public void put(@NonNull String keyName, Float f) {
    mSPUtils.put(keyName, f);
  }

  @Override
  public void put(@NonNull String keyName, Boolean b) {
    mSPUtils.put(keyName, b);
  }

  @Override
  public void put(@NonNull String keyName, String s) {
    mSPUtils.put(keyName, s);
  }

  @Override
  public Integer getInteger(@NonNull String keyName) {
    return mSPUtils.getInt(keyName);
  }

  @Override
  public Long getLong(@NonNull String keyName) {
    return mSPUtils.getLong(keyName);
  }

  @Override
  public Float getFloat(@NonNull String keyName) {
    return mSPUtils.getFloat(keyName);
  }

  @Override
  public Boolean getBoolean(@NonNull String keyName) {
    return mSPUtils.getBoolean(keyName);
  }

  @Override
  public String getString(@NonNull String keyName) {
    return mSPUtils.getString(keyName);
  }
  @Override
  public KVTool getNewInstance() {
    return new DefaultKVTool();
  }

  @Override
  public void exit() {

  }
}